import { defineConfig } from "vite";
import vue from '@vitejs/plugin-vue';
import path from "path";
import packageJson from "./package.json";
import dts from "vite-plugin-dts";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    dts({
      outDir: "dist/types", // 类型声明文件输出目录
      insertTypesEntry: true, // 插入类型声明入口
    }),],
  build: {
    lib: {
      entry: path.resolve(__dirname, "src/index.ts"),
      name: "plugin-uni",
      fileName: (format) => `plugin-uni.${format}.js`,
    },
    rollupOptions: {
      external: [...Object.keys(packageJson.peerDependencies || {})],
      output: {
        globals: {
          vue: "Vue",
          "vue-i18n": "VueI18n",
        },
      }
    }
  }
});
